<template>
	<view class="personChoose">
		<block v-if="isMutil">
			<u-checkbox-group @change="checkboxGroupChange">
				<view class="mulitiLisMore" v-for="(item, index) in dataLis" :key="item.xfOddUserId">
					<u-checkbox @change="checkboxChange($event,index)" v-model="item.checked" :name="item.xfOddUserId">
						<view class="jobCard mL10 mR10" :class="isMutil?'showSqu':''">
							<image class="checkImg" v-if="item.checked" :src="resources.checked" mode=""></image>
							<image class="checkImg" v-else :src="resources.noCheck" mode=""></image>
							<view class="flex  alg-center jst-between">
								<view class="flex alg-center jobLeft"
									@click.stop="xf.onlineUtils.route(`pages/common/personOrcompnayInfo/index?id=${item.xfOddUserId}&isPerson=2`)">
									<view class="jobName  txt-ellipsis font18 bold u-3">{{item.realName}}</view>
									<view class="jobOrgTag   font13 mL5" v-if="item.label">{{item.label}}</view>
								</view>
								<view class="flex alg-center">
									<view @click.stop="callDh(item)">
										<image class="imgW54" :src="resources.job.cirMessage" mode=""></image>
									</view>
									<view class="mL10"  @click.stop="chatJump(item)">
										<image class=" imgW54" :src="resources.job.cirPhone" mode=""></image>
									</view>
								</view>
							</view>
							<view class="font15 mT5">
								<text class="u-6">期望职位：</text>
								<text v-if="define.identification=='units'">{{item.expectPositionText}}</text>
								<text v-else>{{item.expectedPositionText}}</text>


							</view>
							<view class="flex alg-center jst-between mT10">
								<view class="jobPos flex alg-center w70">
									<image class="posImg" :src="resources.posIcon" mode=""></image>
									<text class="posTxt mL5 txt-ellipsis">{{item.homeAddress}}</text>
								</view>
								<view class="font13 u-6" v-if="isDistance">{{item.distance}}</view>
							</view>
							<view class="flex jst-end mT5" v-if="!isMutil">
								<view class="pointer" :class="define.identification=='units'?'bmBtn':'btnTj'"
									@click.stop="grabGive(item)">推荐给Ta</view>
							</view>
						</view>

					</u-checkbox>

				</view>
			</u-checkbox-group>

		</block>
		<block v-else>
			<view class="jobCard  mL15 mR15" v-for="(item, index) in dataLis" :key="item.xfOddjobInfoId">
				<view class="flex  alg-center jst-between">
					<view class="flex alg-center jobLeft"
						@click.stop="xf.onlineUtils.route(`pages/common/personOrcompnayInfo/index?id=${item.xfOddUserId}&isPerson=2`)">
						<view class="jobName  txt-ellipsis font18 bold u-3">{{item.realName}}</view>
						<view class="jobOrgTag   font13 mL5" v-if="item.label">{{item.label}}</view>
					</view>
					<view class="flex alg-center">
						<view @click.stop="callDh(item)">
							<image class="imgW54" :src="resources.job.cirMessage" mode=""></image>

						</view>
						<view class="mL10"  @click.stop="chatJump(item)">
							<image class="imgW54"  :src="resources.job.cirPhone" mode=""></image>
						</view>
					</view>
				</view>
				<view class="employeeInfo" v-if="isEmployeeInfo">
					<view class="flex alg-center">
						<image class="imgW24" :src="resources.qyrzLogo" mode=""></image>
						<view>{{ item.authenticationStateText }}</view>
					</view>
					<view class="mL20 flex alg-center">
						<image class="imgW24" :src="resources.star" mode=""></image>
						<view class="mark">{{ item.evaluationScore }}</view>
					</view>
					<view class="mL20 flex alg-center" v-if="item.orderNumber">
						<view class="font13 orderNumtitle">完成订单</view>
						<view class="font15 orderNum">{{ item.orderNumber }}</view>
					</view>
				</view>
				<view class="font15 mT5">
					<text class="u-6">期望职位：</text>
					<text v-if="define.identification=='units'">{{item.expectPositionText}}</text>
					<text v-else>{{item.expectedPositionText}}</text>
				</view>
				<view class="flex alg-center jst-between mT10">
					<view class="jobPos flex alg-center w70">
						<image class="posImg" :src="resources.posIcon" mode=""></image>
						<text class="posTxt mL5 txt-ellipsis">{{item.homeAddress}}</text>
					</view>
					<view class="font13 u-6" v-if="isDistance">{{item.distance}}</view>
				</view>
				<view class="flex jst-end mT5">
					<block v-if="define.identification=='units'">
						<view class="pointer  mR10 refuseBtn" v-if="showRefuseBtn" @click.stop="grabGive(item)">拒绝Ta
						</view>
						<view class="pointer bmBtn" v-if="isHome"
							@click.stop="xf.onlineUtils.route(`pages/companyPage/subpackge/job/devidePerson/index?distance=${isDistance}&id=${item.xfOddUserId}`)">
							推荐给Ta</view>
						<view class="pointer bmBtn" v-else @click.stop="grabGive(item)">派单给Ta</view>
					</block>
					<block v-else>
						<view class="pointer btnTj" @click.stop="grabGive(item)">推荐给Ta</view>
					</block>

				</view>
			</view>

		</block>
		<xfTipModal ref="tipModal2"></xfTipModal>
	</view>
</template>

<script>
	import {
		rightNowBm
	} from '@/api/userInterface/job.js'
	import { getPhone } from "@/api/userInterface/job"

	export default {
		props: {
			isHome: {
				type: Boolean,
				default: false
			},
			showRefuseBtn: {
				type: Boolean,
				default: false
			},
			isMutil: {
				type: Boolean,
				default: false
			},
			list: {
				type: Array,
				default: []
			},
			isDistance: {
				type: Boolean,
				default: true
			},
			isEmployeeInfo: {
				type: Boolean,
				default: false
			}
		},
		watch: {
			list: {
				immediate: true,
				handler(val) {
					if (this.isMutil && val.length > 0) {
						this.dataLis = val.map(v => {
							return {
								...v,
								checked: false
							}
						})

					}
					this.dataLis = val;
				}
			},

		},
		data() {
			return {
				dataLis: []
			}
		},
		mounted() {
			
		},
		methods: {
			chatJump(item){
				let info = {
					id: item.xfOddUserId,
					realName:item.realName,
					headImage: "",
					online:null
				}
				this.chatStore.addFriend(info)
			},
			callDh(v) {
				let that = this;
				let id = v.xfOddUserId
				getPhone({
					acquirerId: id
				}).then(res => {
					const {result} = res
					if (result.code && result.code == 201){
						let htmlStr = `<p class="mT10">拨打电话需支付<span class="u-red">2元</span></p>`
						this.$refs.tipModal2.open({
							slotHtml: htmlStr,
							btnText: "拨打",
							showCancel: true,
							close() {
								that.showMapTip = true;
							},
							success: function() {
								that.xf.jumpPayPage(`acquirerId=${id}`)
							}
						})
					} else {
						this.$refs.tipModal2.open({
							content: "确认拨打电话吗？",
							btnText: "拨打",
							showCancel: true,
							success: function() {
								that.xf.callPhone({
									acquirerId: id
								})
							}
						})
					}	
				})
				
			},
			grabGive(v) {
				this.$emit('confirm', v)
			},
			checkboxGroupChange(e) {
				if (!this.isMutil) return
				this.$emit("choosePerson", e)
			},
			checkboxChange(e, i) {

			},
			allCheck(e) {
				if (e == false) {
					this.dataLis.map(v => {
						v.checked = false
					})
				} else {
					this.dataLis.map(v => {
						v.checked = true;
					})
				}
			},
			jumpJobDetail(item) {
				uni.navigateTo({
					url: `/pages/userPage/subpackge/oddJob/jobDetail/jobDetail?id=${item.id}`,
				})

			}

		}
	}
</script>

<style lang="scss" scoped>
	.personChoose {
		.u-checkbox-group {
			width: 100%;

		}
	}


	::v-deep .jobCard {
		width: calc(100% - 60rpx) !important;
		padding: 20rpx 30rpx;
		margin-bottom: 20rpx;
		background: #FFFFFF;
		border-radius: 20rpx;
		position: relative;

		&.showSqu {
			padding-left: 66rpx;
			width: 690rpx !important;

			.checkImg {
				width: 32rpx;
				height: 32rpx;
				position: absolute;
				left: 25rpx;
				top: 35rpx;
			}
		}

		.employeeInfo{
			display: flex;
			.mark{
				color: #FF9C00;
				font-size: 30rpx;
			}
			.orderNumtitle{
				color:#666666;
			}
		}

		.u-checkbox__icon-wrap--square {
			display: none;
			position: absolute;
		}

		.u-checkbox__label {
			width: 100% !important;
			margin-left: 0;
			margin-right: 0;
		}

		.jobName {
			// max-width:200rpx;
		}

		.jobLeft {
			width: 70%;
		}

		.jobStatus {
			border: 2rpx solid #FF0000;
			border-radius: 10rpx;
			height: 34rpx;
			line-height: 34rpx;
			padding: 0 10rpx;
			margin-right: 10rpx;
		}

		.jobTag {
			height: 34rpx;
			line-height: 34rpx;
			padding: 0 10rpx;
			background: #F8F8F8;
			border-radius: 6rpx;
		}

		.jobMoney {
			word-break: keep-all;
		}

		.jobTime {
			color: #8D8D8D;
			font-size: 26rpx;
			margin-right: 10rpx;
			height: 44rpx;
			line-height: 44rpx;
			padding: 0 20rpx;
			background: #F8F8F8;
			border-radius: 6rpx;
			margin-top: 16rpx;
		}

		.posImg {
			width: 32rpx;
			height: 32rpx;
		}

		.posTxt {
			width: calc(100% - 42rpx);
			font-weight: 400;
			font-size: 26rpx;
			color: #8D8D8D;
		}

		.companyImg {
			width: 48rpx;
			height: 48rpx;
		}

		.rzImg {
			width: 24rpx;
			height: 24rpx;
		}

		.companyName {
			font-weight: 500;
			font-size: 30rpx;
			color: #333;
			margin-right: 10rpx;
			margin-left: 10rpx;
		}
	}
</style>